package org.example.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.entity.dto.AuthorDTO;
import org.example.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Aaron
 * @since 2020/12/23 13:15
 * <p>描述：</p>
 */
@Slf4j
@RestController
@RequestMapping("/author")
public class AuthorController extends BaseController {

    private final AuthorService authorService;

    @Autowired
    public AuthorController(AuthorService authorService) {
        this.authorService = authorService;
    }


    @PostMapping("/save")
    public CommonResponse<Integer> saveAuthor(@RequestBody AuthorDTO authorDTO) {
        return error("失败");
    }

    @DeleteMapping("/{userId}")
    public CommonResponse<Integer> deleteAuthorById(@PathVariable Long userId) {
        return error("失败");
    }

    @PutMapping("/update")
    public CommonResponse<Integer> updateAuthor(@RequestBody AuthorDTO authorDTO) {
        return error("失败");
    }


    @GetMapping("/getAuthorById")
    public CommonResponse<AuthorDTO> getAuthorById(@RequestParam Long id) {
        log.debug("根据 id 查询：{}", id);
        return authorService.getAuthorById(id);
    }

    @GetMapping("/listAuthors")
    public CommonResponse<AuthorDTO> listAuthors(@RequestParam Long id) {
        log.debug("根据 id 查询：{}", id);
        return error("失败");
    }
}
